package com.wfuhui.modules.oms.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wfuhui.modules.oms.entity.BalanceRecordEntity;
import com.wfuhui.modules.oms.service.BalanceRecordService;
import com.wfuhui.common.utils.Query;
import com.wfuhui.common.utils.R;


/**
 * 金额变动
 * 

 */
@RestController
@RequestMapping("/oms/balancerecord")
public class BalanceRecordController {
	@Autowired
	private BalanceRecordService balanceRecordService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("mall:balancerecord:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<BalanceRecordEntity> balanceRecordList = balanceRecordService.queryList(query);
		int total = balanceRecordService.queryTotal(query);
		
		return R.ok().put("rows", balanceRecordList).put("total", total);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("mall:balancerecord:info")
	public R info(@PathVariable("id") Integer id){
		BalanceRecordEntity balanceRecord = balanceRecordService.queryObject(id);
		
		return R.ok().put("balanceRecord", balanceRecord);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("mall:balancerecord:save")
	public R save(@RequestBody BalanceRecordEntity balanceRecord){
		balanceRecordService.save(balanceRecord);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("mall:balancerecord:update")
	public R update(@RequestBody BalanceRecordEntity balanceRecord){
		balanceRecordService.update(balanceRecord);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("mall:balancerecord:delete")
	public R delete(@RequestBody Integer[] ids){
		balanceRecordService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
